//
//  DemoView.m
//  Demo-002-
//
//  Created by 王奎卿 on 2017/5/8.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "DemoView.h"

@implementation DemoView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self addSubview:self.tableView];
        
        [self demoOne];
    }
    return self;
}

- (void)demoOne
{
    self.arr = [NSMutableArray arrayWithObjects:@"陈奕迅",@"靳东",@"迪丽热巴",@"郑湫泓",@"杨幂",@"关晓彤", nil];
}

- (UITableView *)tableView
{
    UITableView *table = ({
    
        UITableView *tt = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStyleGrouped];
        
        tt.delegate = self;
        
        tt.dataSource = self;
        
        tt;
    });
    
    return table;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
    }
    cell.textLabel.text = self.arr[indexPath.row];
    
    return cell;
}

@end
DemoView *demo (id name){
    DemoView *demo = [[DemoView alloc]init];
    
    return demo;
}
